//
//  TopListTableViewCell.m
//  DolphinMusic
//
//  Created by dllo on 15/3/25.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "TopListTableViewCell.h"

@implementation TopListTableViewCell

- (void)dealloc
{
    [_nameLabel release];
    [_coverImageView release];
    [_firstLabel release];
    [_secondLabel release];
    [_thirdLabel release];
    [_arrowImageView release];
    [_topList release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.coverImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.coverImageView];
        [_coverImageView release];
        
        self.nameLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.nameLabel];
        [_nameLabel release];
        
        self.firstLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.firstLabel];
        [_firstLabel release];
        
        self.secondLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.secondLabel];
        [_secondLabel release];

        self.thirdLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.thirdLabel];
        [_thirdLabel release];

        self.arrowImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.arrowImageView];
        [_arrowImageView release];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.coverImageView.frame = CGRectMake(5, 12.5, 115, 115);
    [self.coverImageView setImageWithURL:[NSURL URLWithString:[self.topList.pic_s192 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
    
    self.nameLabel.frame = CGRectMake(125, 0, self.contentView.frame.size.width - 125 - 30, 30);
    self.nameLabel.text = self.topList.name;
    self.nameLabel.font = [UIFont systemFontOfSize:18];
    
    self.firstLabel.frame = CGRectMake(125, 40, self.contentView.frame.size.width - 125 - 30, 20);
    self.firstLabel.font = [UIFont systemFontOfSize:13];
    Song *song1 = self.topList.songArr[0];
    NSMutableAttributedString *str1 = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"1 %@-%@", song1.title, song1.author]];
    [str1 addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 1)];
    self.firstLabel.attributedText = str1;
    [str1 release];
    
    self.secondLabel.frame = CGRectMake(125, 70, self.contentView.frame.size.width - 125 - 30, 20);
    self.secondLabel.font = [UIFont systemFontOfSize:13];
    Song *song2 = self.topList.songArr[1];
    NSMutableAttributedString *str2 = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"2 %@-%@", song2.title, song2.author]];
    [str2 addAttribute:NSForegroundColorAttributeName value:[UIColor orangeColor] range:NSMakeRange(0, 1)];
    self.secondLabel.attributedText = str2;
    [str2 release];
    
    
    self.thirdLabel.frame = CGRectMake(125, 100, self.contentView.frame.size.width - 125 - 30, 20);
    self.thirdLabel.font = [UIFont systemFontOfSize:13];
    Song *song3 = self.topList.songArr[2];
    NSMutableAttributedString *str3 = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"3 %@-%@", song3.title, song3.author]];
    [str3 addAttribute:NSForegroundColorAttributeName value:[UIColor colorFromHexCode:@"#ffd400"] range:NSMakeRange(0, 1)];
    self.thirdLabel.attributedText = str3;
    [str3 release];
    
    self.arrowImageView.frame = CGRectMake(self.contentView.frame.size.width - 25, 60, 20, 20);
    self.arrowImageView.image = [UIImage imageNamed:@"arrowNext.png"];
    self.arrowImageView.alpha = 0.7;
    
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
